/**
 * @author LKQ
 * @date 2022/2/26 11:29
 * @description 差分数组
 */
public class FormalSolution {
    public static void main(String[] args) {
        int[][] booking = {{1,2,10},{2,3,20},{2,5,25}};
        FormalSolution formalSolution = new FormalSolution();
        formalSolution.corpFlightBookings(booking, 5);
    }
    public int[] corpFlightBookings(int[][] bookings, int n) {
        int[] nums = new int[n];
        for (int[] booking : bookings) {
            nums[booking[0] - 1] += booking[2];
            if (booking[1] < n) {
                nums[booking[1]] -= booking[2];
            }
        }
        for (int i = 1; i < n; i++) {
            nums[i] += nums[i - 1];
        }
        return nums;
    }

}
